<?php
defined('JOC') or die;
/**
 * Description of R
 *
 * @author jcamelis
 */
class R {
  static function get( $index = '' , $type = 'string' )
  {
    global $request ;
    return R::escape($request->get($index),$type);
  }
  static function post( $index = '' , $type = 'string' )
  {
    global $request ;
    return R::escape($request->post($index),$type);
  }
  static function server( $index = '' , $type = 'string' )
  {
    global $request ;
    return R::escape($request->server($index),$type);
  }
  static function all( $index = '' , $type = 'string' )
  {
    global $request ;
    return R::escape($request->all($index),$type);
  }
  static function escape( $var , $type )
  {
    switch ($type){
      case 'int' :
        return is_array($var) ? array_map('intval',$var) : intval($var);
        break ;
      case 'string' :
        return is_array($var) ? array_map('mysql_escape_string',$var) : mysql_escape_string($var);
        break ;
    }
  }
}
